home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / nihcl-30.lha / nihcl-3.0 / lib / Set.h < prev    next >
C/C++ Source or Header  |  1990-05-19  |  2KB  |  70 lines

  1. #ifndef    SET_H
  2. #define    SET_H
  3.  
  4. /*$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/lib/RCS/Set.h,v 3.0 90/05/20 00:21:18 kgorlen Rel $*/
  5.  
  6. /* Set.h -- declarations for hash tables
  7.  
  8.     THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
  9.     "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
  10.     AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
  11.     CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
  12.     PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
  13.     RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
  14.  
  15. Author:
  16.     K. E. Gorlen
  17.     Computer Systems Laboratory, DCRT
  18.     National Institutes of Health
  19.     Bethesda, MD 20892
  20.  
  21. $Log:    Set.h,v $
  22.  * Revision 3.0  90/05/20  00:21:18  kgorlen
  23.  * Release for 1st edition.
  24.  * 
  25. */
  26.  
  27. #include "Collection.h"
  28. #include "ArrayOb.h"
  29.  
  30. class Set: public Collection {
  31.     DECLARE_MEMBERS(Set);
  32.     unsigned count;        // number of objects in set 
  33.     unsigned nbits;        // log base 2 of contents.capacity() 
  34. protected:
  35.     unsigned mask;        // contents.capacity()-1 
  36.     ArrayOb contents;    // array of set objects 
  37.     unsigned setCapacity(unsigned);    // compute set allocation size 
  38.     int h(unsigned long) const;    // convert hash key into contents index 
  39.     virtual int findIndexOf(const Object&) const;
  40. protected:        // storer() functions for object I/O
  41.     virtual void storer(OIOofd&) const;
  42.     virtual void storer(OIOout&) const;
  43. public:
  44.     Set(unsigned size =DEFAULT_CAPACITY);
  45.     bool operator==(const Set&) const;
  46.     bool operator!=(const Set& a) const    { return !(*this==a); }
  47.     Set operator&(const Set&) const;    // intersection 
  48.     Set operator|(const Set&) const;    // union 
  49.     Set operator-(const Set&) const;    // difference 
  50.     virtual    Object*    add(Object&);
  51.     virtual Object*& at(int);
  52.     virtual const Object *const& at(int) const;
  53.     virtual unsigned capacity() const;
  54.     virtual void deepenShallowCopy();
  55.     virtual Object*    doNext(Iterator&) const;
  56.     virtual    Object* findObjectWithKey(const Object&) const;
  57.     virtual unsigned hash() const;
  58.     virtual bool isEqual(const Object&) const;
  59.     virtual unsigned occurrencesOf(const Object&) const;
  60.     virtual void reSize(unsigned);
  61.     virtual Object*    remove(const Object&);
  62.     virtual void removeAll();
  63.     virtual unsigned size() const;
  64.     virtual const Class* species() const;
  65. private:                // shouldNotImplement()
  66.     virtual int compare(const Object&) const;
  67. };
  68.  
  69. #endif
  70.